package com.example.javabasic.sample.reflection.load;

import java.lang.reflect.Method;

/**
 * @author: cph
 * @date: 2022/1/13 16:51
 */
public class Test {
    public static void main(String[] args) {
        try {
            Rule rule1 = new Rule()
                    .setId(1001L)
                    .setName("test1")
                    .setType(1);

            Rule rule2 = new Rule()
                    .setId(1002L)
                    .setName("test2")
                    .setType(2);

            Class clazz = Class.forName("com.example.javabasic.sample.reflection.load.FilterRule");
            Object obj = clazz.newInstance();
            Method method = clazz.getMethod("doFilter", Rule.class);

            Object result1 = method.invoke(obj, rule1);
            System.out.println(Integer.valueOf(result1.toString()));

            Object result2 = method.invoke(obj, rule2);
            System.out.println(Integer.valueOf(result2.toString()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
